/**
 * 飞机基类
 */
var BasePlane = require('./../BasePlane');
var EnumBody = require('./../../Enum/EnumBody');
var EnumPlane = require('./../../Enum/EnumPlane');
var EnumProp = require('./../../Enum/EnumProp');
var BaseProp = require('./../../Prop/BaseProp');
module.exports = cc.Class(
{
    extends: BasePlane,
    onLoad()
    {
        this._super();

        this.eatGlodCnt = 0; //吃到金币的数量
        this.eatDiamondCnt = 0; //吃到钻石的数量
    },

    onCollisionEnter: function(other)
    {
        var body = this._super(other);
        if (null == body)
        {
            return;
        }
        var bodyType = body.getEnumBody();
        if (EnumBody.PLANE == bodyType)
        {
            var planeCtr = other.getComponent(BasePlane);
            if (null == planeCtr)
            {
                cc.error('飞机没带管理脚本');
                return;
            }
            var enumPlane = planeCtr.getEnumPlane();
            if (EnumPlane.ENEMY == enumPlane)
            {
                this.playBomb();
                this.node.destroy();
                cc.log('飞机碰撞销毁 - my');
                this.node.emit('die');
            }
        }
        else if (EnumBody.PROP == bodyType)
        {
            //道具
            var propCtr = other.getComponent(BaseProp);

            var enumProp = propCtr.getEnumProp();
            // if (EnumProp.GOLD == propCtr.getEnumProp())
            // {

            // }
            // else if (EnumProp.DIAMOND == propCtr.getEnumProp())
            // {

            // }

            this.node.emit('eatProp', enumProp, 1);
            other.node.destroy();
        }
    },

    onLoad()
    {
        this._super();
        this.setEnumPlane(EnumPlane.MY);
        this.node.runAction(cc.moveBy(1, cc.v2(0, cc.winSize.height * 0.2)));
    },

    registerRemove(cb)
    {
        this.cb = cb;
    }
});